home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Games Collection 1 / software vault.zip / software vault / CDR02 / DCGAMES1.ZIP / NEWGAME.ZIP / OBJECT.SCR < prev    next >
Text File  |  1993-04-01  |  39KB  |  1,163 lines

  1. !
  2. ! Default script OBJECT.SCR.
  3. !
  4. ! This is the default script for handling objects.  It is invoked whenever
  5. ! an object is manipulated (Talk, Get, Drop, Wear, Remove, Look, Examine,
  6. ! Invoke, Use and Exit) under the following conditions:
  7. !
  8. ! a) If the object has a script assigned to it, that script is invoked
  9. !    first.
  10. ! b) If the object's script terminates with CONTINUE, or if the object
  11. !    does not have a script, then this script is invoked.
  12. !
  13. ! You may modify this script at will, but one thing to remember is that
  14. ! this script should NEVER terminate with CONTINUE.  The reason is that
  15. ! objects may explicitly state that their script is 'OBJECT', in which
  16. ! case a 'CONTINUE' would execute this script twice! (Once as the script
  17. ! assigned to the object, and another time because the script ended with
  18. ! continue).
  19. !
  20. ! (c) DC Software, 1992
  21. !
  22.  
  23. !------------------------------------------------------------------------!
  24. :@TALK ! Talk to the object !
  25. !------------------------------------------------------------------------!
  26.   if npc.count then
  27.     writeln( "The ", npc.type, " has nothing to say.." );
  28.   else
  29.     writeln( "How do you talk to an ", object.type, "?" );
  30.   endif;
  31.   STOP;
  32.  
  33. !------------------------------------------------------------------------!
  34. :@GET ! Get the object (pick it up) !
  35. !------------------------------------------------------------------------!
  36.   if npc.count then writeln( "You can't do that.." ); STOP; endif;
  37.   if object.endgame = END_ON_GET then  ! Game ends on a GET of this object !
  38.     if object.endtext > 0 then         ! .. this text is displayed first.. !
  39.       readtext( object.endtext );
  40.     endif;                             ! .. then the game ends. !
  41.     ENDGAME;
  42.   endif;
  43.   if object.type = CHEST and object.locktype then ! Locked !
  44.     writeln( "You must first UNLOCK the chest, then GET the gold!" );
  45.   elsif object.type = CHEST or object.type = GOLDSACK then
  46.     if object.value = 0 then
  47.       L1 = object.count * player.hp * 10 + random( 100 ) + 1;
  48.     else
  49.       L1 = object.value * object.count;
  50.       if L1 <= 0 then
  51.         L1 = object.value;
  52.       endif;
  53.     endif;
  54.     writeln( "Got ", $L1, " (gold pieces)."  );
  55.     group.gold = group.gold + L1;
  56.     vanish( object );
  57.   elsif object.type = FOOD and object.class = 0 then
  58.     writeln( "Got ", object.count, " units of food." );
  59.     group.food = group.food + object.count;
  60.     vanish( object );
  61.   elsif object.weight = 999 then
  62.     writeln( "The ", object.name, " is much too heavy." );
  63.   elsif object.weight = 998 then
  64.     writeln( "The ", object.name, " is can't be moved." );
  65.   elsif object.weight = 997 then
  66.     writeln( "Why would you want to take the ", object.name, "?" );
  67.   elsif object.weight > 255 then
  68.     writeln( "You can't move it!" );
  69.   elsif object.weight > player.mload then
  70.     writeln( "You are not strong enough to carry it!" );
  71.   elsif object.weight > 1 and object.weight + player.load > player.mload then
  72.     writeln( "Your load is too heavy!" );
  73.   else
  74.     L0 = object.count;
  75.     move( object, player.bp );  ! OBJECT does not exist after MOVE !
  76.     if success then
  77.       writeln("Got ", L0, " ", player.bp.name );
  78.     elsif object.count = L0 then
  79.       writeln("You couldn't carry it");
  80.     else
  81.       writeln("You could only carry ", L0 - object.count, " of them." );
  82.     endif;
  83.   endif;
  84.   STOP;
  85.  
  86. !------------------------------------------------------------------------!
  87. :@DROP      ! Drop the object on the floor !
  88. !------------------------------------------------------------------------!
  89.   if curritem.count > 1 then
  90.     L0 = getnum( "How many? ", 0, curritem.count );
  91.     if L0 > 0 then 
  92.       drop( curritem, L0 );  
  93.     endif;
  94.   else
  95.     drop( curritem );
  96.   endif;
  97.   writeln( "Ok." );
  98.   STOP;
  99.  
  100. !------------------------------------------------------------------------!
  101. :@WEAR      ! Wear or Wield the object !
  102. !------------------------------------------------------------------------!
  103.   L0 = 0;  ! Hands needed to hold the item..
  104.  
  105.   on curritem.type goto
  106.    WR_FOOD,     WR_WEAPON,     WR_AMMO,      WR_ARMOR,      WR_SHIELD,
  107.    WR_AMULET,   WR_RING,       WR_POTION,    WR_SCROLL,     WR_STAFF;
  108. !
  109. ! the rest can't be worn, so no need to list them..
  110. !  WR_CHEST,    WR_KEYS,       WR_GEMS,      WR_BOOK,       WR_GOLDSACK,
  111. !  WR_TORCH,    WR_LANTERN,    WR_ROPE,      WR_HOOKS,      WR_MIRROR,
  112. !  WR_SIGN,     WR_VEHICLE
  113. !
  114.  
  115. :WR_FOOD
  116. :WR_AMMO
  117. :WR_POTION
  118. :WR_SCROLL
  119.    writeln( "How do you wear a ", curritem.type, "? " );
  120.    STOP;
  121.  
  122. :WR_WEAPON
  123.    if (player.class = ELF or player.class = WIZARD or player.class = ARCHER) 
  124.       and curritem.weight > 5 + adjustments(player.str) then
  125.      writeln( "This weapon is too heavy for this character class." );
  126.    elsif player.class = WIZARD and curritem.hands > 1 then
  127.      writeln( "Wizards can only use one-handed weapons" );
  128.    elsif (player.class = WIZARD or player.class = DWARF) and curritem.class = MISSILE then
  129.      writeln( "Wizards and dwarfs can't use non-magical missile weapons" );
  130.    elsif player.weapon.count > 0 then
  131.      writeln( "You must first remove the ", player.weapon.name );
  132.    else
  133.      L0 = curritem.hands; ! Hands needed to hold the weapon !
  134.      S0 = "wielding";
  135.      goto WR_DOIT;
  136.    endif;
  137.    STOP;
  138.  
  139. :WR_ARMOR
  140.    if (player.class = ELF or player.class = WIZARD) and
  141.       curritem.weight > 5 + adjustments(player.str) then
  142.      writeln( "This weapon is too heavy for an elf or a wizard" );
  143.    elsif player.class = ARCHER and
  144.       curritem.weight > 10 + adjustments(player.str) then
  145.      writeln( "This weapon is too cumbersome for an archer" );
  146.    elsif player.armor.count > 0 then
  147.      writeln( "You must first remove the ", player.armor.name );
  148.    else
  149.      S0 = "wearing";
  150.      goto WR_DOIT;
  151.    endif;
  152.    STOP;
  153.  
  154. :WR_SHIELD
  155.    if player.class = WIZARD or player.class = ARCHER or player.class = DWARF then
  156.      writeln( player.class, "s cannot use a shield!" );
  157.    elsif player.class = ELF and curritem.weight > 5 + adjustments(player.str) then
  158.      writeln( "The shield is too heavy for an ELF." );
  159.    elsif player.shield.count > 0 then
  160.      writeln( "You must first remove the ", player.shield.name );
  161.    else
  162.      L0 = 1;             ! A shield always needs 1 hand.. !
  163.      S0 = "using";
  164.      goto WR_DOIT;
  165.    endif;
  166.    STOP;
  167.  
  168. :WR_STAFF
  169.    L0 = 1;             ! A staff always needs 1 hand.. !
  170.    if player.class = FIGHTER then
  171.      writeln( "Fighters can't use magic staffs." );
  172.    elsif curritem.charges = 0 then
  173.      writeln( "The staff has no charges left.." );
  174.    elsif player.staff.count > 0 then
  175.      writeln( "You must first remove the ", player.staff.name );
  176.    else
  177.      S0 = "holding";
  178.      goto WR_DOIT;
  179.    endif;
  180.    STOP;
  181.  
  182. :WR_AMULET
  183. :WR_RING
  184.    if player.class = FIGHTER then
  185.      writeln( "Fighters can't use magic ", curritem.type, "s." );
  186.    elsif curritem.charges = 0 then
  187.      writeln( "The ", curritem.type, " has no charges left.." );
  188.    elsif curritem.type = AMULET and player.amulet.count > 0 then
  189.      writeln( "You must first remove the ", player.amulet.name );
  190.    elsif curritem.type = RING and player.ring.count > 0 then
  191.      writeln( "You must first remove the ", player.ring.name );
  192.    else
  193.      S0 = "wearing";
  194.      goto WR_DOIT;
  195.    endif;
  196.    STOP;
  197.  
  198. :WR_DOIT
  199.   L1 = 2; ! Player has 2 hands.. !
  200.   if player.weapon.count then dec( L1, player.weapon.hands ); endif;
  201.   if player.shield.count then dec( L1, 1 );                   endif;
  202.   if player.staff.count  then dec( L1, 1 );                   endif;
  203.   if L0 > L1 then
  204.     writeln( "You don't have enough free hands!" );
  205.     STOP;
  206.   endif;
  207.   !
  208.   move( curritem, player.body, 1 );
  209.   if success then
  210.     writeln( "You are now ", s0, " the ", player.body.name );
  211.     if player.body.type = ARMOR or player.body.type = SHIELD then
  212.       if player.armor.cursed or player.shield.cursed then
  213.         player.ac = 0;
  214.       else
  215.         inc(player.ac,player.body.ac);
  216.       endif;
  217.     elsif player.body.type = RING or player.body.type = AMULET then
  218.       if( player.body.charges > 0 ) then
  219.         curritem = player.body;
  220.         gosub M1_INVOKE;
  221.         if curritem.charges < 255 then
  222.           dec( curritem.charges );
  223.         endif;
  224.       else
  225.         writeln( "The ", player.body.type, " has no charges." );
  226.       endif;
  227.     endif;
  228.   endif;
  229.   STOP;
  230.  
  231. !------------------------------------------------------------------------!
  232. :@REMOVE    ! Remove an object !
  233. !------------------------------------------------------------------------!
  234.   if curritem.cursed then
  235.     writeln( "The ", curritem.type, " is cursed and cannot be removed.." );
  236.     STOP;
  237.   endif;
  238.   move( curritem, player.bp, 1 );
  239.   if success then
  240.     writeln( "You remove the ", player.bp.name );
  241.   endif;
  242.   STOP;
  243.  
  244. !------------------------------------------------------------------------!
  245. :@LOOK      ! Look at an object                                          !
  246. !------------------------------------------------------------------------!
  247.   L255 = FALSE;   ! Do not give DETAILED description !
  248.   gosub DESCRIBE;
  249.   STOP;
  250.  
  251. !------------------------------------------------------------------------!
  252. :@EXAMINE   ! Examine the object in detail                               !
  253. !------------------------------------------------------------------------!
  254.   L255 = TRUE;   ! Give DETAILED description !
  255.   gosub DESCRIBE;
  256.   STOP;
  257.  
  258. !------------------------------------------------------------------------!
  259. :@INVOKE  ! Invoke an object we are carrying..
  260. !------------------------------------------------------------------------!
  261. !
  262. ! Called when an object we are carrying in the backpack or that we are
  263. ! wearing has a magical effect that needs to be executed.  The effect
  264. ! may be of type 1 (food,potion,ring,amulet,gem) or type 2 (scroll,staff).
  265. !
  266.   if curritem.endgame = END_ON_USE then
  267.     if curritem.endtext > 0 then         ! .. this text is displayed first.. !
  268.       readtext( curritem.endtext );
  269.     endif;                             ! .. then the game ends. !
  270.     ENDGAME;
  271.   endif;
  272.   if curritem.type = FOOD or curritem.type = POTION then
  273.     player.energy = 255;     ! Not hungry any more.. 
  274.     gosub M1_INVOKE;
  275.     dec( curritem.count );
  276.   elsif curritem.type = SCROLL or curritem.type = STAFF then
  277.     gosub M2_INVOKE;
  278.   elsif curritem.type = GEMS or curritem.type = RING or curritem.type = AMULET then
  279.     gosub M1_INVOKE;
  280.     if curritem.charges < 255 then
  281.       dec( curritem.charges );
  282.       if curritem.type = GEMS and curritem.charges = 0 then
  283.         writeln( "The ", curritem.type, " vanishes after you use it." );
  284.         dec( curritem.count );
  285.       endif;
  286.     endif;
  287.   else
  288.     writeln( "The ", curritem.name, " has no magical properties.." );  
  289.   endif;
  290.   STOP;
  291.  
  292. !------------------------------------------------------------------------!
  293. :@USE ! Use an object laying on the ground before us..
  294. !------------------------------------------------------------------------!
  295. !
  296. ! Called when an object that is laying on the ground is 'used'.  Note that
  297. ! 'use' means different things for different object types, and that in 
  298. ! order to invoke an item you have 'get' it and sometimes 'wear' it.
  299. !
  300.   if object.endgame = END_ON_USE then
  301.     if object.endtext > 0 then         ! .. this text is displayed first.. !
  302.       readtext( object.endtext );
  303.     endif;                             ! .. then the game ends. !
  304.     ENDGAME;
  305.   endif;
  306.  
  307.   on object.type goto
  308.    USE_FOOD,     USE_WEAPON,     USE_AMMO,      USE_ARMOR,      USE_SHIELD,
  309.    USE_AMULET,   USE_RING,       USE_POTION,    USE_SCROLL,     USE_STAFF,
  310.    USE_CHEST,    USE_KEYS,       USE_GEMS,      USE_BOOK,       USE_GOLDSACK,
  311.    USE_TORCH,    USE_LANTERN,    USE_ROPE,      USE_HOOKS,      USE_MIRROR,
  312.    USE_SIGN,     USE_VEHICLE;
  313.  
  314.   writeln( "I don't know how to do that with the ", object.name );
  315.   STOP;
  316.  
  317.   :USE_FOOD
  318.   :USE_POTION
  319.      if object.class then
  320.        writeln( "You must 'get' it, then 'quaff' (eat) it.." );
  321.      else
  322.        writeln( "Just 'get' it.." );
  323.      endif;
  324.      STOP;
  325.  
  326.   :USE_GEMS
  327.   :USE_SCROLL
  328.      writeln( "You must first 'get' it, then 'invoke' it.." );
  329.      STOP;
  330.  
  331.   :USE_AMULET
  332.   :USE_RING
  333.   :USE_ARMOR
  334.   :USE_WEAPON
  335.   :USE_SHIELD
  336.   :USE_STAFF
  337.      writeln( "You must first 'get' it, then 'wear' or 'wield' it.." );
  338.      STOP;
  339.  
  340.   :USE_AMMO
  341.      writeln( "Just carry it in your backpack.  If you 'wield' a " );
  342.      writeln( "weapon that uses this type of ammo, it will get used" );
  343.      writeln( "automaticly." );
  344.      STOP;
  345.  
  346.   :USE_CHEST
  347.      ! Unlock the chest !
  348.      if object.locktype then
  349.        L0 = 0;
  350.        :UCLOOP
  351.           setbp( player, L0 );
  352.           if player.bp.type = KEYS and player.bp.keytype = object.locktype then
  353.             writeln( object.name, " unlocked.." );
  354.             object.locktype = 0;
  355.             STOP;
  356.           endif;
  357.           inc( L0 );
  358.           if L0 < 16 goto :UCLOOP;
  359.        writeln( "You don't have the right key!  Break the lock?" );
  360.        if getstr( "Yes", "No" ) = 0 then
  361.          if random( 2 + adjustments(player.str) ) > 0 then
  362.            write( "You broke the lock!" );
  363.            if object.traptype = 1 then
  364.              voice( "Argh", 1000 ); ! 1000 = DCSOUNDS.VFL !
  365.              writeln( "Argh.. Poison trap!" );
  366.              player.poisoned = 1;
  367.            elsif object.traptype > 1 then
  368.              voice( "Explode", 1000 ); ! Play standard sound effect !
  369.              writeln( "Bomb Trap!" );
  370.              dec( player.hp, object.damage );
  371.              if player.hp = 0 then
  372.                writeln( player.name, " has died.." );
  373.              endif;
  374.            endif;
  375.            object.locktype = 0;
  376.          else
  377.            writeln( "It doesn't break!" );
  378.          endif;
  379.        else
  380.           writeln( "Ok." );
  381.        endif;
  382.      else
  383.        writeln( "It is not locked.." );
  384.      endif;
  385.      STOP;
  386.  
  387.   :USE_KEYS
  388.      writeln( "Just 'Get' it and carry it in case you find a lock that" );
  389.      writeln( "the key can open!" );
  390.      STOP;
  391.  
  392.   :USE_BOOK
  393.      writeln( "To read it, just 'Look' at it.." );
  394.      STOP;
  395.  
  396.   :USE_GOLDSACK
  397.      L1 = getnum("How many gold pieces do you want to put in it?",
  398.                          0, group.gold / 10) * 10;
  399.      if L1 then
  400.        writeln( "You put ", $L1, " in the bag." );
  401.        inc( object.value, L1 );
  402.        dec( group.gold, L1 );
  403.      else
  404.        writeln( "Smart move.." );
  405.      endif;
  406.      STOP;
  407.  
  408.   :USE_TORCH
  409.   :USE_LANTERN
  410.      writeln( "Save your torches.. I haven't implemented LIGHT yet!" );
  411.      STOP;
  412.  
  413.   :USE_ROPE
  414.      writeln( "After fooling around with it for a while, you manage to" );
  415.      writeln( "get yourself tangled up..." );
  416.      STOP;
  417.  
  418.   :USE_HOOKS
  419.      voice( "Ouch", 1000 );
  420.      writeln( "Ouch! (it's sharp!)" );
  421.      STOP;
  422.  
  423.   :USE_MIRROR
  424.      writeln( "Yes, you are ugly, but that doesn't matter here.." );
  425.      STOP;
  426.  
  427.   :USE_SIGN
  428.      writeln( "It's not yours.  You can 'Read' it if you wish.." );
  429.      STOP;
  430.  
  431.   :USE_VEHICLE
  432.      if group.vehicle.count then
  433.        writeln( "You must first exit the one you are in!" );
  434.        STOP;
  435.      endif;
  436.      if object.x <> group.x and object.y <> group.y then
  437.        writeln( "You must be standing next to the ", object.name );
  438.      else
  439.        group.x = object.x;            ! Move over to it !
  440.        group.y = object.y;            
  441.        move( object, group.vehicle, 1 ); ! Now board the object !
  442.        if success then
  443.          writeln( "You are on riding the ", group.vehicle.name );
  444.        endif;
  445.      endif;
  446.      STOP;
  447.  
  448. !------------------------------------------------------------------------!
  449. :@EXIT ! Exit a VEHICLE (since this is an object we are talking about..)
  450. !------------------------------------------------------------------------!
  451.   if curritem.count = 0 then
  452.     writeln("You are already on foot!" );
  453.     STOP;
  454.   endif;
  455.   if curritem.type <> VEHICLE then
  456.     writeln("BUG: CURRITEM in :@EXIT in OBJECT.SCR is not a vehicle!" );
  457.   endif;
  458.   if group.vehicle.count = 0 then
  459.     writeln("BUG: CURRITEM is not GROUP.VEHICLE on @EXIT in OBJECT.SCR" );
  460.   endif;
  461.   drop( group.vehicle );
  462.   voice( "Exit", 1000 );
  463.   writeln( "You are now on foot.." );
  464.   STOP;
  465.  
  466. !------------------------------------------------------------------------!
  467. !--  SCRIPT SUBROUTINES ARE GROUPED HERE AT THE END.  THIS IS A CHOICE --!
  468. !--  NOT A REQUIREMENT.  IT MAKES THE MAIN SCRIPT CODE ABOVE A LITTLE  --!
  469. !--  BIT EASIER TO FOLLOW.  ---------------------------------------------!
  470. !------------------------------------------------------------------------!
  471.  
  472. !------------------------------------------------------------------------!
  473. !
  474. ! SUBROUTINE: DESCRIBE
  475. !
  476. ! This routine is invoked from @LOOK, @EXAMINE and by the ANALYZE spell
  477. ! to describe a given item.
  478. !
  479. !------------------------------------------------------------------------!
  480. :DESCRIBE
  481. !------------------------------------------------------------------------!
  482.  
  483. ! First, handle the case where you are looking at a CHARACTER
  484.  
  485.   if npc.count then
  486.     if npc.picture >= 0 then
  487.       viewpcx( npc );
  488.       if success then
  489.         pause;
  490.       endif;
  491.       paint( screen );
  492.     endif;
  493.     write( "Name: ", npc.name, ", Type: ", npc.type );
  494.     if npc.type = HOSTILE and npc.weapon.count then
  495.       write( ", Weapon: ", npc.weapon.name, ", Damage: ", npc.weapon.damage, ", Range: ", npc.weapon.range );
  496.     endif;
  497.     if L255 then
  498.       write( ", Class: ", npc.class, ", Lvl: ", npc.level, ", AC: ", npc.ac, ", HP: ", npc.hp );
  499.     endif;
  500.     writeln(".");
  501.     STOP;
  502.   endif;
  503.   if object.picture >= 0 then
  504.     viewpcx( object );
  505.     if success then
  506.       pause;
  507.     endif;
  508.     paint( screen );
  509.   elsif object.type = SIGN or object.type = BOOK then
  510.     readtext( object.text );
  511.     STOP;
  512.   endif;
  513.   write( "You see a ", object.name );
  514.   if NOT L255 then
  515.     writeln;
  516.     STOP;
  517.   endif;
  518.   write( ", Type: ", object.type );
  519. !
  520. ! The following is a 'cascading if..then..elsif..elsif.....else..endif' 
  521. ! statement.  It is used here to illustrate it's usefulness.  The same
  522. ! code could have been written with a 'ON object.type GOTO' statement.
  523. !
  524.   if object.type = FOOD or object.type = POTION  then
  525.     if object.class then
  526.       write( ", Class: ", object.class );
  527.       if object.class <> CURE then
  528.         write( ", Units: ", object.units );
  529.       endif;
  530.     endif;
  531.   elsif object.type = WEAPON then
  532.     write( ", Class: ", object.class, 
  533.            ", Hands: ", object.hands, 
  534.            ", Range: ", object.range, 
  535.            ", Damage: ", object.damage );
  536.     if object.ammoneeded then
  537.       write( ", Needs ammo type: ", object.ammo_type );
  538.     endif;
  539.   elsif object.type = AMMO then
  540.     write( ", Ammo Type: ", object.ammotype );
  541.     if object.traptype then
  542.       write( ", Poisoned" );
  543.     endif;
  544.     if object.damage then
  545.       write( ", Extra Damage: ", object.damage );
  546.     endif;
  547.   elsif object.type = ARMOR or object.type = SHIELD then
  548.     write( ", Armor Class: ", object.ac );
  549.     if object.cursed then
  550.       write( " Cursed!" );
  551.     endif;
  552.   elsif object.type = AMULET or object.type = RING or object.type = GEMS then
  553.     if object.class then
  554.       write( ", Class: ", object.class );
  555.       write( ", Charges: ", object.charges );
  556.       if object.class <> CURE then
  557.         write( ", Units: ", object.units );
  558.         if object.permanent then
  559.           write( ", Permanent!" );
  560.         else
  561.           write( ", Temporary" );
  562.         endif;
  563.       endif;
  564.       if object.cursed then
  565.         write( ", Cursed!" );
  566.       endif;
  567.     endif;
  568.   elsif object.type = SCROLL then
  569.     write( ", Class: ", object.class );
  570.   elsif object.type = STAFF then
  571.     write( ", Class: ", object.class, ", Charges: ", object.charges );
  572.   elsif object.type = CHEST then
  573.     if object.locktype then
  574.       write( ", Locked!" );
  575.       if object.traptype = 0 then
  576.         write( ", no traps" );
  577.       elsif object.traptype = 1 then
  578.         write( ", poison trap" );
  579.       else
  580.         write( ", bomb damage: ", object.traptype );
  581.       endif;
  582.     endif;
  583. ! elsif object.type = KEYS     then
  584. !   nothing special about it
  585. ! elsif object.type = BOOK     then
  586. !   nothing special about it
  587. ! elsif object.type = GOLDSACK then
  588. !   nothing special about it
  589. ! elsif object.type = TORCH    then
  590. !   nothing special about it
  591. ! elsif object.type = LANTERN  then
  592. !   nothing special about it
  593. ! elsif object.type = ROPE     then
  594. !   nothing special about it
  595. ! elsif object.type = HOOKS    then
  596. !   nothing special about it
  597. ! elsif object.type = MIRROR   then
  598. !   nothing special about it
  599. ! elsif object.type = SIGN     then
  600. !   nothing special about it
  601.   elsif object.type = VEHICLE then
  602.     write( ", Class: ", object.class );
  603. ! else
  604. !   user defined type?
  605.   endif;
  606.   if object.weight > 1 and object.weight < 256 then
  607.     write( ", Weight: ", object.weight );
  608.   endif;
  609.   writeln( "." );
  610.   return;
  611.  
  612. !------------------------------------------------------------------------!
  613. !
  614. ! SUBROUTINE: M1_INVOKE
  615. !
  616. ! Type 1 Magic - Affects the person invoking the magic..
  617. !
  618. ! This portion of the script is invoked whenever an individual in the
  619. ! adventurer's group:
  620. !
  621. !  a) Eats food that has a magical effect
  622. !  b) Drinks a potion with a magical effect
  623. !  c) Successfully wears a ring or an amulet with a magical effect
  624. !  d) Uses a GEM that has a magical effect.
  625. !
  626. ! When invoked, PLAYER is the person that will be affected, and CURRITEM
  627. ! is the item that has the magical effect, and which is either being
  628. ! worn or in the character's backpack.  OBJECT and NPC are not defined.
  629. !
  630. !------------------------------------------------------------------------!
  631. :M1_INVOKE
  632. !------------------------------------------------------------------------!
  633.  
  634.   if curritem.cursed and curritem.permanent then
  635.     curritem.permanent = FALSE;
  636.     writeln( "WARNING: This object was 'cursed' and had 'permanent' effect!" );
  637.     writeln( "WARNING: The effect has been made 'temporary' by OBJECT.SCR" );
  638.   endif;
  639.  
  640.   on curritem.class goto
  641.     M1_NONE,    M1_CURE,    M1_HEAL,    M1_POISON,    M1_RESTORE,
  642.     M1_STR,     M1_DEX,     M1_SPD,     M1_AIM,       M1_AC,
  643.     M1_HP,      M1_IQ,      M1_PWR;
  644.  
  645. :M1_NONE
  646.   writeln( "Nothing happens.." );
  647.   return;
  648.  
  649. :M1_CURE
  650.   if player.poisoned then
  651.     player.poisoned = 0;
  652.     writeln( player.name, " is now cured." );
  653.   else
  654.     writeln( "Nothing happens.." );
  655.   endif;
  656.   return;
  657.  
  658. :M1_HEAL
  659.   if player.hp >= player.mhp then
  660.     writeln( "Nothing happens.." );
  661.   elsif player.hp = 0 then
  662.     writeln( player.name, " is beyond help.." );
  663.   else
  664.     if curritem.units > 0 then
  665.       L0 = curritem.units;                   ! always heals the same points !
  666.     else
  667.       L0 = random(player.mhp - player.hp)+1; ! heal a random number of points !
  668.     endif;
  669.     voice( "Tada", 1000 );
  670.     if player.hp + L0 < player.mhp then
  671.       writeln( player.name, " heals ", L0, " hit points.." );
  672.       inc( player.hp, L0 );
  673.     else
  674.       writeln( player.name, " has been completely healed!" );
  675.       player.hp = player.mhp;
  676.     endif;
  677.   endif;
  678.   return;
  679.  
  680. :M1_POISON
  681.   if NOT player.poisoned then
  682.     player.poisoned = 1;
  683.     voice( "DudSpell", 1000 );
  684.     writeln( "You feel sick.." );
  685.   else
  686.     voice( "Boing", 1000 );
  687.     writeln( "You feel worse.." );
  688.   endif;
  689.   return;
  690.  
  691. :M1_RESTORE
  692.   if player.hp >= player.mhp then
  693.     writeln( "Nothing happens.." );
  694.   elsif player.hp = 0 then
  695.     writeln( player.name, " is beyond help.." );
  696.   else
  697.     voice( "OkSpell", 1000 );
  698.     player.hp = player.mhp;
  699.     writeln( player.name, " is completely healed!" );
  700.   endif;
  701.   return;
  702.  
  703. :M1_STR
  704.   if curritem.cursed then
  705.     player.str = 0;
  706.     voice( "DudSpell", 1000 );
  707.     writeln( "Something went wrong.." );
  708.   else
  709.     voice( "OkSpell", 1000 );
  710.     inc( player.hp, curritem.units );
  711.     if curritem.permanent then
  712.       inc( player.mhp, curritem.units );
  713.     endif;
  714.     writeln( player.name, "'s strength increased by ", curritem.units, "!" );
  715.   endif;
  716.   return;
  717.  
  718. :M1_DEX
  719.   if curritem.cursed then
  720.     player.dex = 0;
  721.     voice( "DudSpell", 1000 );
  722.     writeln( "Something went wrong.." );
  723.   else
  724.     voice( "OkSpell", 1000 );
  725.     inc( player.dex, curritem.units );
  726.     if curritem.permanent then
  727.       inc( player.mdex, curritem.units );
  728.     endif;
  729.     writeln( player.name, "'s dexterity increased by ", curritem.units, "!" );
  730.   endif;
  731.   return;
  732.  
  733. :M1_SPD
  734.   if curritem.cursed then
  735.     player.spd = 0;
  736.     voice( "DudSpell", 1000 );
  737.     writeln( "Something went wrong.." );
  738.   else
  739.     voice( "OkSpell", 1000 );
  740.     inc( player.spd, curritem.units );
  741.     if curritem.permanent then
  742.       inc( player.mspd, curritem.units );
  743.     endif;
  744.     writeln( player.name, "'s speed increased by ", curritem.units, "!" );
  745.   endif;
  746.   return;
  747.  
  748. :M1_AIM
  749.   if curritem.cursed then
  750.     player.aim = 0;
  751.     voice( "DudSpell", 1000 );
  752.     writeln( "Something went wrong.." );
  753.   else
  754.     voice( "OkSpell", 1000 );
  755.     inc( player.aim, curritem.units );
  756.     if curritem.permanent then
  757.       inc( player.maim, curritem.units );
  758.     endif;
  759.     writeln( player.name, "'s aim increased by ", curritem.units, "!" );
  760.   endif;
  761.   return;
  762.  
  763. :M1_AC
  764.   if curritem.cursed then
  765.     player.ac = 0;
  766.     voice( "DudSpell", 1000 );
  767.     writeln( "Something went wrong.." );
  768.   else
  769.     voice( "OkSpell", 1000 );
  770.     inc( player.ac, curritem.units );
  771.     if curritem.permanent then
  772.       inc( player.mac, curritem.units );
  773.     endif;
  774.     writeln( player.name, "'s armor class increased by ", curritem.units, "!" );
  775.   endif;
  776.   return;
  777.  
  778. :M1_HP
  779.   if curritem.cursed then
  780.     player.hp = player.hp / 3 + 1;
  781.     writeln( player.name, " has been seriously injured!" );
  782.   else
  783.     voice( "OkSpell", 1000 );
  784.     inc( player.hp, curritem.units );
  785.     if curritem.permanent then
  786.       inc( player.mhp, curritem.units );
  787.     endif;
  788.     writeln( player.name, "'s hit points increased by ", curritem.units, "!" );
  789.   endif;
  790.   return;
  791.  
  792. :M1_IQ
  793.   if curritem.cursed then
  794.     player.iq = 0;
  795.     voice( "DudSpell", 1000 );
  796.     writeln( "Something went wrong.." );
  797.   else
  798.     voice( "OkSpell", 1000 );
  799.     inc( player.iq, curritem.units );
  800.     if curritem.permanent then
  801.       inc( player.miq, curritem.units );
  802.     endif;
  803.     writeln( player.name, "'s i.q. increased by ", curritem.units, "!" );
  804.   endif;
  805.   return;
  806.  
  807. :M1_PWR
  808.   if player.class = ELF or player.class = WIZARD then
  809.     if curritem.cursed then
  810.       player.pwr = 0;
  811.       voice( "DudSpell", 1000 );
  812.       writeln( "Something went wrong.." );
  813.     else
  814.       inc( player.pwr, curritem.units );
  815.       if curritem.permanent then
  816.         inc( player.mpwr, curritem.units );
  817.       endif;
  818.       voice( "OkSpell", 1000 );
  819.       writeln( player.name, "'s power increased by ", curritem.units, "!" );
  820.     endif;
  821.   else
  822.     voice( "Argh", 1000 );
  823.     write( player.name, " screams and falls to the ground, " );
  824.     if player.hp < 3 then
  825.       writeln( "dead!" );
  826.       player.hp = 0;
  827.     else
  828.       writeln( "holding his head.." );
  829.       dec( player.hp, 2 );
  830.     endif;
  831.   endif;
  832.   return;
  833.     
  834. !------------------------------------------------------------------------!
  835. !
  836. ! SUBROUTINE: M2_INVOKE
  837. !
  838. ! Type 2 Magic - Affects an object or a another person
  839. !
  840. ! This portion of the script handles magic spells which affect objects
  841. ! or persons other than the caster.  When invoked, the PLAYER is the
  842. ! person that invoked the spell and CURRITEM is the object that was used
  843. ! to invoke the spell (which is either being worn or carried by the
  844. ! player).
  845. !
  846. ! The OBJECT and NPC are undefined.  If the spell requires a target,
  847. ! the 'LOCATE' function can be used to select an object or character
  848. ! to cast the spell on.  The locate function returns the distance in blocks
  849. ! to the selected target.  If none is selected, the value is -1, and FAILURE
  850. ! is set.
  851. !
  852. ! After a LOCATE, either OBJECT or NPC will be set depending on whether the
  853. ! user selected an object or a character (or monster, during a fight).
  854. !
  855. ! To figure out which one was selected, check if NPC.COUNT is greater than
  856. ! 0.  If it is, a character was selected.  If it is not, then an object was
  857. ! selected.
  858. !
  859. !------------------------------------------------------------------------!
  860. :M2_INVOKE
  861. !------------------------------------------------------------------------!
  862.  
  863.   if curritem.class = NONE then
  864.     writeln( "Nothing happens.." );
  865.     return;
  866.   endif;
  867.  
  868.   if curritem.count = 0 then
  869.     writeln( "Oops, no object in OBJECT.SCR, m2 invoke" );
  870.     stop;
  871.   endif;
  872.  
  873.   if curritem.class = DAMAGE or curritem.class = CONFUSE or
  874.      curritem.class = SCARE  or curritem.class = PARALYZE or
  875.      curritem.class = KILL then
  876.     if not fighting then
  877.       writeln( "This spell can only be used during a fight.." );
  878.       return;
  879.     endif;
  880.     !
  881.     ! L5 will contain the TOTAL experience points gained when done..
  882.     ! L6 is the maximum damage that will be done to a single monster..
  883.     ! L8 is the maximum total damage that can be done to a group of monsters..
  884.     ! L9 is the TOTAL number of monsters affected AFTER the spell
  885.     !
  886.     L5 = 0;
  887.     L6 = player.level + adjustments(player.pwr) / 2 + 1;
  888.     if L6 <= 0 then
  889.       writeln( "The spell failed.." );
  890.       STOP;
  891.     endif;
  892.     if curritem.units then
  893.       L8 = curritem.units;
  894.     else
  895.       L8 = player.iq + adjustments(player.iq);
  896.     endif;
  897.     L9 = 0;
  898.   endif;
  899.  
  900.   if curritem.type = STAFF and curritem.charges = 0 then
  901.     writeln( "The ", curritem.name, " doesn't work.." );
  902.     return;
  903.   endif;
  904.      
  905.   if curritem.class <> LEAVE  and
  906.      curritem.class <> ZOOM   and
  907.      curritem.class <> INFORM and
  908.      curritem.class <> DOORS  and
  909.      curritem.class <> RESURRECT then
  910.     write( object.class, " what:" );
  911.     L1 = locate;
  912.     if L1 = 0 then
  913.       writeln( "nothing.." );
  914.       return;
  915.     endif;
  916.     if npc.count then ! It's a character, not an object..
  917.       if npc.type = HOSTILE then
  918.         writeln( npc.name );  ! monster's don't have classes.. !
  919.       else
  920.         writeln( npc.class ); ! Human, elf, dwarf, etc..       !
  921.       endif;
  922.       if curritem.class = DESTROY  or curritem.class = DUPLICATE or
  923.          curritem.class = RECHARGE or curritem.class = FLOAT then
  924.         writeln( "This spell only work's on objects!" );
  925.         goto M2_EXIT;
  926.       endif;
  927.     else
  928.       writeln( object.type );  ! Food, weapon, ring, etc..      !
  929.     endif;
  930.   endif;
  931.  
  932.   on curritem.class goto 
  933.     M2_EXIT,     M2_DESTROY,  M2_DUPLICATE, M2_LEAVE,
  934.     M2_RESURRECT,M2_INFORM,   M2_LOCATE,    M2_KILL, 
  935.     M2_CONFUSE,  M2_SCARE,    M2_DAMAGE,    M2_PARALYZE,
  936.     M2_RECHARGE, M2_FLOAT,    M2_ANALYZE,   M2_ZOOM;
  937.  
  938. :M2_NONE      ! No magic..
  939.   writeln( "Nothing happens.." );
  940.   goto M2_EXIT;
  941.  
  942. :M2_DESTROY   ! Destroy an object                      pwr = 5, rng=10
  943.   ! if player.pwr < 5 goto M2_NOPOWER; ! No power check needed
  944.   if L1 > 10 goto M2_OUTOFRANGE;
  945.   voice( "Explode", 1000 );
  946.   writeln( "The ", object.type, " is destroyed.." );
  947.   vanish( object );
  948.   L4 = 5;
  949.   goto M2_EXIT;
  950.  
  951. :M2_DUPLICATE ! Duplicates an object                   pwr = 40, rng=1
  952.   ! if player.pwr < 40 goto M2_NOPOWER; ! No power check needed
  953.   if L1 > 1 goto M2_OUTOFRANGE;
  954.   inc( object.count, 1 ); ! Creates an identical copy ! 
  955.   L4 = 40;
  956.   goto M2_EXIT;
  957.  
  958. :M2_LEAVE     ! Exit through the 'exit' door from anywhere...  
  959.   if world.type <> DUNGEON then
  960.     voice( "Boing", 1000 );
  961.     writeln( "This spell only work's in dungeons.." );
  962.     return;
  963.   endif;
  964.   ! if player.pwr < 5 goto M2_NOPOWER; ! No power check needed
  965.   enter( world.edgedoor );
  966.   voice( "OkSpell", 1000 );
  967.   writeln( "You leave this level of the dungeon.." );
  968.   L4 = 5;
  969.   goto M2_EXIT;
  970.  
  971. :M2_RESURRECT ! Revive a DEAD person                   pwr = 50, rng=1
  972.   ! if player.pwr < 50 goto M2_NOPOWER; ! No power check needed
  973.   if L1 > 1 goto M2_OUTOFRANGE;
  974.   write( "Resurrect: " );
  975.   L0 = select( group );
  976.   if player.hp > 0 then
  977.     voice( "Boing", 1000 );
  978.     writeln( "This player is NOT dead!" );
  979.     return;
  980.   endif;
  981.   voice( "OkSpell", 1000 );
  982.   writeln( player.name );
  983.   player.hp  = 2;
  984.   writeln( player.name, " is alive, but weak.." );
  985.   L4 = 50;
  986.   goto M2_EXIT;
  987.   
  988. :M2_INFORM    ! Displays some text                     pwr =  5
  989.   ! if player.pwr < 5 goto M2_NOPOWER; ! No power check needed
  990.   if L1 > 5 goto M2_OUTOFRANGE;
  991.   loadhint;
  992.   writeln( "The wind seems to carry a random phrase to your ears.." );
  993.   writeln( s0 );
  994.   L4 = 5;
  995.   goto M2_EXIT;
  996.  
  997. :M2_LOCATE    ! Locate doors                           pwr = 10
  998.   ! if player.pwr < 10 goto M2_NOPOWER; ! No power check needed
  999.   if L1 > 10 goto M2_OUTOFRANGE;
  1000.   L0 = 0;
  1001.   :LDLOOP
  1002.     if world.doorx(L0) > 0 and world.doory(L0) > 0 then
  1003.       frame( world.doorx(L0), world.doory(L0), SYS_FRAME );
  1004.     endif;
  1005.     inc(L0);
  1006.   if L0 < 16 goto LDLOOP;
  1007.   L4 = 10;
  1008.   goto M2_EXIT;
  1009.  
  1010. :M2_KILL      ! Kill 1 enemy during battle             pwr = 20, rng=6
  1011.   writeln( npc.name, " killed. +", npc.hp, " exp." );
  1012.   inc( player.exp, npc.hp );
  1013.   npc.hp = 0;
  1014.   STOP;
  1015.  
  1016. :M2_DAMAGE    ! Causes damage to monsters              pwr =  5, rng=12
  1017.   S0 = "hit";
  1018.   foreach npc do
  1019.     L7 = min( npc.hp, random(L6) );  ! How much damage to this one monster?
  1020.     if L7 > 0 then
  1021.       frame(npc.x, npc.y, SYS_SPLAT); wait(1); frame(npc.x, npc.y, SYS_SPLAT);
  1022.       write( npc.name );
  1023.       if L7 < npc.hp then
  1024.         write( " hit." );
  1025.         dec( npc.hp, L7 );           ! Hit the monster..
  1026.       else
  1027.         write( " killed!" );
  1028.         npc.hp = 0;
  1029.       endif;
  1030.       writeln( " +", L7, " exp." );
  1031.       inc(L9);                       ! Count of affected npcs
  1032.       inc( L5, L7 );                 ! Accumulate experience..
  1033.       if L5 > L8 goto DCSPEXIT;      ! Stop when total of L8 points used
  1034.     endif;
  1035.   endfor;  
  1036.   goto DCSPEXIT;
  1037.  
  1038. :M2_CONFUSE   ! Makes monsters shoot at other monsters pwr =  1, rng=12
  1039.   S0 = "confused";
  1040.   foreach npc do
  1041.     L7 = min( npc.hp, random(L6) );  ! How much confusion to this one monster?
  1042.     if L7 > 0 and npc.confused = 0 then
  1043.       frame(npc.x, npc.y, SYS_SPLAT); wait(1); frame(npc.x, npc.y, SYS_SPLAT);
  1044.       inc(L9);                       ! Count of affected npcs
  1045.       npc.confused = L7;             ! Confuse for 'n' units
  1046.       inc( L5, L7 );                 ! Accumulate experience..
  1047.       if L5 > L8 goto DCSPEXIT;      ! Stop when total of L8 points used
  1048.     endif;
  1049.   endfor;  
  1050.   goto DCSPEXIT;
  1051.  
  1052. :M2_SCARE     ! Scares monsters                        pwr =  2, rng=12
  1053.   S0 = "scared";
  1054.   foreach npc do
  1055.     L7 = min( npc.hp, random(L6) );  ! How much 'fright' to this one monster?
  1056.     if L7 > 0 and npc.scared = 0 then
  1057.       frame(npc.x, npc.y, SYS_SPLAT); wait(1); frame(npc.x, npc.y, SYS_SPLAT);
  1058.       inc(L9);
  1059.       npc.scared = L7;               ! Frighten for 'n' units
  1060.       inc( L5, L7 );                 ! Accumulate experience..
  1061.       if L5 > L8 goto DCSPEXIT;      ! Stop when total of L8 points used
  1062.     endif;
  1063.   endfor;  
  1064.   goto DCSPEXIT;
  1065.  
  1066. :M2_PARALYZE  ! Monster can't move                     pwr =  5, rng=12
  1067.   S0 = "paralyzed";
  1068.   foreach npc do
  1069.     L7 = min( npc.hp, random(L6) );  ! How much paralysis to this one monster?
  1070.     if L7 > 0 and npc.paralyzed = 0 then
  1071.       frame(npc.x, npc.y, SYS_SPLAT); wait(1); frame(npc.x, npc.y, SYS_SPLAT);
  1072.       inc(L9);
  1073.       npc.paralyzed = L7;            ! Paralyze for 'n' units
  1074.       inc( L5, L7 );                 ! Accumulate experience..
  1075.       if L5 > L8 goto DCSPEXIT;      ! Stop when total of L8 points used
  1076.     endif;
  1077.   endfor;  
  1078.   goto DCSPEXIT;
  1079.  
  1080. :M2_RECHARGE  ! Recharge an ITEM                       pwr = 25, rng=1
  1081.   ! if player.pwr < 25 goto M2_NOPOWER; ! No power check needed
  1082.   if L1 > 1 goto M2_OUTOFRANGE;
  1083.   if object.type = RING or object.type = AMULET or object.type = STAFF then
  1084.     inc( object.charges, random(player.level)+1 );
  1085.     voice( "OkSpell", 1000 );
  1086.     writeln( "The ", object.type, " now has ", object.charges, " charges." );
  1087.   else
  1088.     voice( "Boing", 1000 );
  1089.     writeln( "The smell of rotten eggs fills the air.." );
  1090.   endif;
  1091.   L4 = 25;
  1092.   goto M2_EXIT;
  1093.  
  1094. :M2_FLOAT     ! Remove an object's weight              pwr = 10, rng=1
  1095.   ! if player.pwr < 10 goto M2_NOPOWER; ! No power check needed
  1096.   if L1 > 1 goto M2_OUTOFRANGE;
  1097.   if object.weight < 255 then
  1098.     object.weight = object.weight / 2 + 1;
  1099.     voice( "OkSpell", 1000 );
  1100.     writeln( "The ", object.type, " is now much lighter.." );
  1101.   else
  1102.     voice( "Boing", 1000 );
  1103.     writeln( "It's didn't work.  The ", object.type, " is too heavy." );
  1104.   endif;
  1105.   L4 = 10;
  1106.   goto M2_EXIT;
  1107.  
  1108. :M2_ANALYZE   ! Discover object's properties           pwr = 10, rng=1
  1109.   ! if player.pwr < 10 goto M2_NOPOWER; ! No power check needed
  1110.   if L1 > 1  goto M2_OUTOFRANGE;
  1111.   L255 = TRUE;   ! Give DETAILED description !
  1112.   gosub DESCRIBE;
  1113.   L4 = 10;
  1114.   goto M2_EXIT;
  1115.  
  1116. :M2_ZOOM      ! View the world.. 
  1117.   ! if player.pwr < 25 goto M2_NOPOWER; ! No power check needed
  1118.   viewpcx( world );
  1119.   if success then
  1120.     pause;
  1121.   endif;
  1122.   paint( screen ); ! If you don't have any WORLD###.PCX files, you can use !
  1123.                    ! paint( WINDOW ) instead of paint( SCREEN) !
  1124.   L4 = 25;
  1125.   goto M2_EXIT;
  1126.  
  1127. :M2_NOPOWER
  1128.   writeln( "You don't have enough power!" );
  1129.   return;
  1130.  
  1131. :M2_OUTOFRANGE
  1132.   writeln( "You are too far away from the ", object.name );
  1133.   return;
  1134.  
  1135. :DCSPEXIT
  1136.   if L9 then
  1137.     write( L9, " foes were ", S0 );
  1138.     if L5 then  
  1139.       writeln( " for a total of +", L5, " experience!" );
  1140.       inc( player.exp, L5 );           ! Grant experience..
  1141.     else
  1142.       writeln( " With no effect" );
  1143.     endif;
  1144.   else
  1145.     writeln( "No effect.." );
  1146.   endif;
  1147.   goto M2_EXIT;
  1148.  
  1149. :M2_EXIT
  1150.   if curritem.count > 0 then
  1151.     if curritem.type = SCROLL then
  1152.       dec( curritem.count ); ! Item disapears if count reaches 0 !
  1153.     elsif curritem.type = STAFF then
  1154.       dec( curritem.charges ); ! One less !
  1155.     endif;
  1156.   else
  1157.     dec( player.pwr, L4 );   ! A spell !
  1158.   endif;
  1159.   return;
  1160.  
  1161.  
  1162.  
  1163.